package com.qf.dao;

import com.qf.pojo.Branch;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @Description: 公用常量
 * @Data: 2022/8/25 22:46
 * @Pacakge: com.qf.dao
 * @ClassName: BranchDao
 * @Author: fan
 * 开发商数据访问接口
 */
public interface BranchDao {
    /**
     * 通过项目id查询对应的开发商部门
     * @param pid 工程编号
     * @return 开发商部门信息列表
     */
    @Select("select * from branch where pid =#{pid} and status = 1")
    List<Branch> findBranchByPid(@Param("pid")Integer pid);

    /**
     * 查询所有开发商以及开发商对应的任务计划
     * @return
     */
    @Results(id = "BranchAndTaskPlanMap",value = {
            @Result(column = "bid",property = "bid"),
            @Result(column = "bname",property = "bname"),
            @Result(column = "updatetime",property = "updatetime"),
            @Result(column = "bid",property = "taskplans",
                    many =@Many(select = "com.qf.dao.TaskplanDao.findTaskPlanByBid",
                                fetchType = FetchType.EAGER)
            )
    })
    @Select("select * from branch where status = 1")
    List<Branch> findAllBranchAndTaskPlan();


}
